#
# Copyright (C) 2010-2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk

PKG_NAME:=fpc
PKG_VERSION:=3.2.2
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).source.tar.gz
PKG_SOURCE_URL:=@SF/freepascal
PKG_HASH:=d542e349de246843d4f164829953d1f5b864126c5b62fd17c9b45b33e23d2f44

PKG_BUILD_PARALLEL:=1
PKG_MAINTAINER:=Han Pengfei <pengphei@foxmail.com>

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/host-build.mk

FPC_OPT = -dFPC_ARMHF -k--build-id -k-z -knoexecstack

MAKE_ENV = \
	CPU_TARGET=$(ARCH) \
	OS_TARGET=linux \
	CROSSBINDIR=$(TOOLCHAIN_DIR)/bin \
	BINUTILSPREFIX=$(TARGET_CROSS) \
	INSTALL_PREFIX=$(STAGING_DIR_HOST) \
	PP=/usr/bin/ppcx64
	

define Package/fpc
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE:=free pascale
  URL:=https://www.freepascal.org/
  DEPENDS:+libpthread
endef

define Package/fpc/description
	Free Pascal is a mature, versatile, open source Pascal compiler. 
endef

define Host/Compile
	cd $(PKG_BUILD_DIR); $(MAKE_ENV) make compiler_cycle OPT='$(FPC_OPT)'
endef

define Build/InstallDev
	true
endef

define Package/fpc/install
	true
endef

$(eval $(call HostBuild))
$(eval $(call BuildPackage,fpc))
